/*
 * Copyright (c) 2017. Chengdu Qianxing Technology Co.,LTD.
 * All Rights Reserved.
 */
package com.daqsoft.dto;

/**
 *
 * 本服务器设计用于通用消息返回格式
 *
 * 
 * @scene 1.0
 * 
 * @author Alan
 *
 */
public class GeneralResultEnum {
	public static final GeneralResultEnum SUCCESS = new GeneralResultEnum(0, "ok");
	public static final GeneralResultEnum FAIL = new GeneralResultEnum(1, "fail");
	public static final GeneralResultEnum PERMISSION_DENIED = new GeneralResultEnum(2, "权限不足");
	public static final GeneralResultEnum NEED_LOGIN = new GeneralResultEnum(3, "请重新登录");
	/**
	 * 服务器响应码
	 */
	private int code;
	/**
	 * 相应数据
	 */
	private Object data;
	/**
	 * 相应描述信息
	 */
	private String desc;

	/**
	 * 是否成功
	 */
	private boolean success;
	/**
	 * 树形结构专有数据
	 */
	private Object children;

	public GeneralResultEnum(int code) {
		super();
		this.code = code;
	}

	public GeneralResultEnum(int code, String desc) {
		super();
		this.code = code;
		this.success = code == 0;
		this.desc = desc;
	}

	public GeneralResultEnum(int code, Object data, String desc) {
		super();
		this.code = code;
		this.data = data;
		this.success = code == 0;
		this.desc = desc;
	}

	public int getCode() {
		return code;
	}

	public GeneralResultEnum setCode(int code) {
		this.code = code;
		this.success = code == 0;
		return this;
	}

	public Object getData() {
		return data;
	}


	public GeneralResultEnum setData(Object data) {
		this.data = data;
		return this;
	}

	public String getDesc() {
		return desc;
	}

	public GeneralResultEnum setDesc(String desc) {
		this.desc = desc;
		return this;
	}

	public boolean isSuccess() {
		return success;
	}

	public Object getChildren() {
		return children;
	}

	public GeneralResultEnum setChildren(Object children) {
		this.children = children;
		return this;
	}
}
